home *** CD-ROM | disk | FTP | other *** search
/ The Trig Explorer / The Trig Explorer.iso / mac / Explorer / plot.dxr / 00059.ls < prev    next >
Encoding:
Text File  |  2000-08-01  |  3.0 KB  |  89 lines

  1. on mouseDown me
  2.   set xCenter to the locH of sprite 3
  3.   set yCenter to the locV of sprite 3
  4.   set radius to the width of sprite 4 / 2
  5.   set the cursor of sprite the spriteNum of me to [member "Closed Hand", member "Closed Hand Mask"]
  6.   repeat while the stillDown
  7.     set mx to the mouseH
  8.     set my to the mouseV
  9.     set xAtMouse to mx - xCenter
  10.     set yAtMouse to my - yCenter
  11.     if xAtMouse <> 0 then
  12.       set angleAtMouse to atan(float(abs(yAtMouse)) / float(abs(xAtMouse)))
  13.       if angleAtMouse = 0 then
  14.         set yAtCircle to 0
  15.         set xAtCircle to radius * (xAtMouse / abs(xAtMouse))
  16.       else
  17.         set yAtCircle to sin(angleAtMouse) * float(radius) * (yAtMouse / abs(yAtMouse))
  18.         set xAtCircle to cos(angleAtMouse) * float(radius) * (xAtMouse / abs(xAtMouse))
  19.       end if
  20.     else
  21.       set xAtCircle to 0
  22.       if yAtMouse <> 0 then
  23.         set yAtCircle to radius * (yAtMouse / abs(yAtMouse))
  24.       else
  25.         set yAtCircle to radius
  26.       end if
  27.     end if
  28.     set the locH of sprite the clickOn to xCenter + xAtCircle
  29.     set the locV of sprite the clickOn to yCenter + yAtCircle
  30.     drawLine(5, yCenter, xCenter, the locV of sprite the clickOn, the locH of sprite the clickOn)
  31.     set dy to float(yCenter - the locV of sprite the clickOn)
  32.     set dy to -dy
  33.     set dx to float(xCenter - the locH of sprite the clickOn)
  34.     if dx = 0 then
  35.       if dy < 0 then
  36.         set theta1 to float(1.5 * PI)
  37.       else
  38.         set theta1 to float(PI / 2.0)
  39.       end if
  40.     else
  41.       if dx > 0 then
  42.         set theta1 to float(atan(float(dy / dx)))
  43.         if theta1 < 0 then
  44.           set theta1 to float(theta1) + (2.0 * PI)
  45.         end if
  46.       else
  47.         set theta1 to float(atan(float(dy / dx))) + PI
  48.       end if
  49.     end if
  50.     set the floatPrecision to 2
  51.     if theta1 > PI then
  52.       set theta1 to theta1 - PI
  53.     else
  54.       set theta1 to theta1 + PI
  55.     end if
  56.     set tempT to theta1 * 180.0 / PI
  57.     put float(1.0 * float(cos(theta1))) into field "X1"
  58.     set Y1temp to float(1.0 * float(sin(theta1)))
  59.     put "(" & field "X1" & "," & Y1temp & ")" into field "x-y"
  60.     if value(field "X1") = 0 then
  61.       put "Undef." into field "Y1"
  62.     else
  63.       put float(1.0 * float(tan(theta1))) into field "Y1"
  64.     end if
  65.     set x0 to the locH of sprite 15
  66.     set y0 to the locV of sprite 15
  67.     if (field "theta" <> 90.0) or (field "theta" <> 270.0) then
  68.       set the locH of sprite 19 to (0.80000000000000004 * tempT) + x0
  69.       set the locV of sprite 19 to y0 - (50 * tan(theta1))
  70.     end if
  71.     if the hilite of cast "Degrees" then
  72.       put theta1 * 180.0 / PI into field "theta"
  73.     else
  74.       put theta1 into field "theta"
  75.     end if
  76.     updateStage()
  77.   end repeat
  78.   set the cursor of sprite the spriteNum of me to [member "Hand", member "Hand Mask"]
  79. end
  80.  
  81. on beginSprite
  82.   initializeCircle()
  83.   set the hilite of cast "Degrees" to 1
  84.   set the hilite of cast "Radians" to 0
  85.   set the castNum of sprite 16 to cast "Degs"
  86.   put "(1.00, 0.02)" into field "x-y"
  87.   put "0.02" into field "Y1"
  88. end
  89.